package com.kefu.smartCall.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.vo.AbstractSearchVo;
import com.kefu.smartCall.model.ScTaskCall;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Objects;

@Data
@ApiModel
public class ScTaskCallSearchVo extends AbstractSearchVo {
    @ApiModelProperty("任务")
    private String taskId;

    @ApiModelProperty(value = "用户回复数(大于这个数)")
    private Integer userMsgCountMin;

    @ApiModelProperty(value = "通话时长，秒(大于这个数)")
    private Integer callDurationMin;

    @ApiModelProperty(value = "大模型筛选状态 0=未选，-1=不通过，1=通过", name = "searchState")
    private Integer searchStatus;

    @Override
    public LambdaQueryWrapper lambdaQuery() {
        LambdaQueryWrapper<ScTaskCall> wrapper = Wrappers.lambdaQuery(ScTaskCall.class);
        if (StrUtil.isNotBlank(taskId)) {
            wrapper.eq(ScTaskCall::getTaskId, taskId);
        }
        if (Objects.nonNull(userMsgCountMin)) {
            wrapper.eq(ScTaskCall::getUserMsgCount, userMsgCountMin);
        }
        if (Objects.nonNull(callDurationMin)) {
            wrapper.gt(ScTaskCall::getCallDuration, callDurationMin);
        }
        if (Objects.nonNull(searchStatus)) {
            wrapper.eq(ScTaskCall::getSearchStatus, searchStatus);
        }
        // 只有“已接通”的外呼记录才能被搜索到
        wrapper.eq(ScTaskCall::getCallStatus, 2);
        return wrapper;
    }
}
